package framework.dubbo.spi;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * dubbo SPI 测试类
 *
 * @author ME
 * @date 2021/5/8
 */
public class TestDubboSPI {

    @Test
    public void sayHello() {
        ExtensionLoader<Robot> extensionLoader = ExtensionLoader.getExtensionLoader(Robot.class);

        Robot bumblebee = extensionLoader.getExtension("bumblebee");
        bumblebee.sayHello();

        Robot optimusPrime = extensionLoader.getDefaultExtension();
        optimusPrime.sayHello();

        assertEquals("默认 SPI扩展的名字为：optimusPrime",
                "optimusPrime", extensionLoader.getDefaultExtensionName());
    }
}
